package cuiyt.offer;

/**
 * @author cyt
 * @create 2020-05-20 10:49
 */
public class T16 {

    /**
     * 翻转链表
     *
     * @param head
     * @return
     */
    public ListNode ReverseList(ListNode head) {

        if (head == null) {
            return head;
        }


        ListNode newList = new ListNode(-1);
        while (head != null) {
            ListNode next = head.next;
            head.next = newList.next;
            newList.next = head;
            head = next;
        }
        return newList.next;


    }
}
